package xixirupan.tmgp.tencent.com.vmeim.ui.beautyshop.presenter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import java.util.List;

import xixirupan.tmgp.tencent.com.vmeim.R;
import xixirupan.tmgp.tencent.com.vmeim.config.URLConfig;
import xixirupan.tmgp.tencent.com.vmeim.ui.beautyshop.model.Nav1BannersBaen;

/**
 * Created by lenovo on 2016/10/19.
 */

public class RecyIndexItem2Adapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    List<Nav1BannersBaen>  topBanners ;
    Context context;
    LayoutInflater inflater;
    public   RecyIndexItem2Adapter(List<Nav1BannersBaen>  topBanners, Context context, LayoutInflater inflater)
    {
        this.topBanners =topBanners;
        this.context =context;
        this.inflater =inflater;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

         ViewHolderItem2 holderItem2 =new ViewHolderItem2(inflater.inflate(R.layout.item2_index_layout,parent,false));
        return holderItem2;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
       if (holder instanceof ViewHolderItem2)
       {
           String name = topBanners.get(position).getName();
           ((ViewHolderItem2) holder).textView_title.setText(name);
           String _imgURL = topBanners.get(position).getImgURL();
           String imgURL = URLConfig.Url.BASE_URL+_imgURL;
           Glide.with(context).load(imgURL).into(((ViewHolderItem2) holder).imageView_icon);
       }
    }

    @Override
    public int getItemCount() {
        return topBanners.size();
    }
    class ViewHolderItem2 extends RecyclerView.ViewHolder
    {
           ImageView imageView_icon;
        TextView textView_title;

        public ViewHolderItem2(View itemView) {
            super(itemView);
            imageView_icon = (ImageView) itemView.findViewById(R.id.imageViewin_item2_index);
            textView_title = (TextView) itemView.findViewById(R.id.item2_initextView_index);
        }
    }
}
